#include "Control_Interface.h"

#include "Host.h"
#include "StatusComponent.h"

using namespace gui;

Control_Interface::Control_Interface(
	std::function <void()> NewRefreshFunction,
	std::function <void(RendererComponent& Renderer)> NewUpdateVerticesFunction,
	std::function <void()> NewMouseMoveFunction,
	std::function <void()> NewMouseDownLeftFunction,
	std::function <void()> NewMouseUpLeftFunction,
	std::function <void()> NewMouseDownRightFunction,
	std::function <void()> NewMouseUpRightFunction,
	Host& NewParentHost) :
	RefreshFunction(NewRefreshFunction),
	UpdateVerticesFunction(NewUpdateVerticesFunction),
	MouseMoveFunction(NewMouseMoveFunction),
	MouseDownLeftFunction(NewMouseDownLeftFunction),
	MouseUpLeftFunction(NewMouseUpLeftFunction),
	MouseDownRightFunction(NewMouseDownRightFunction),
	MouseUpRightFunction(NewMouseUpRightFunction),
	Control_Base(nullptr, NewParentHost),
	Status(NewParentHost.Status)
{
}

Control_Interface::Control_Interface(Host& NewParentHost) :
RefreshFunction([](){}),
UpdateVerticesFunction([](RendererComponent& Renderer){}),
MouseMoveFunction([](){}),
MouseDownLeftFunction([](){}),
MouseUpLeftFunction([](){}),
MouseDownRightFunction([](){}),
MouseUpRightFunction([](){}),
Control_Base(nullptr, NewParentHost),
Status(NewParentHost.Status)
{
}

Control_Interface::~Control_Interface(void)
{
}

void Control_Interface::UpdateVerticesFast(RendererComponent& Renderer)
{
	UpdateVerticesFunction(Renderer);
}


void Control_Interface::MouseMove()
{
	if (!Status.InterfaceHasFocus)
		return;
	MouseMoveFunction();
}

void Control_Interface::MouseDownLeft()
{
	
	if (!Status.InterfaceHasFocus)
		return;
	MouseDownLeftFunction();

}

void Control_Interface::MouseUpLeft()
{
	
	if (!Status.InterfaceHasFocus)
		return;
	MouseUpLeftFunction();
}

void Control_Interface::MouseDownRight()
{
	if (!Status.InterfaceHasFocus)
		return;
	MouseDownRightFunction();
}

void Control_Interface::MouseUpRight()
{
	
	if (!Status.InterfaceHasFocus)
		return;
	MouseUpRightFunction();
}

void Control_Interface::Refresh()
{
	RefreshFunction();
}

void Control_Interface::SetFocus(bool NewFocus)
{
	if (NewFocus != Status.InterfaceHasFocus)
	{
		Status.InterfaceHasFocus = NewFocus;
	}
}

